import json
from cross_chain_data.code_new.code_scan.etherScan import get_ethScan_data
f=open('../data_new/bug_xulie.json','r',encoding='utf-8')
content=f.read()
f.close()
total_data=json.loads(content)

print(type(total_data))

print(len(total_data))
data_bug_raw=[]
i=1
for data_dict in total_data:
    data_raw_dict={}
    if i<=56:
        tx_s=data_dict["Lock_event"]["tx_s"][2:]
        tx_d=data_dict["Unlock_event"]["tx_d"][2:]
        if len(tx_s)>=5 :
            data_raw_dict["source_chain_data"] = get_ethScan_data(tx_s)
        else:
            data_raw_dict["source_chain_data"]={}
        data_raw_dict["cross_chain_data"] = {}
        if len(tx_d)>=5 :
            data_raw_dict["target_chain_data"] = get_ethScan_data(tx_d)
        else:
            data_raw_dict["target_chain_data"]={}
        data_raw_dict["Type"]="0"

        data_bug_raw.append(data_raw_dict)
    i=i+1
print(len(data_bug_raw))

json_data=json.dumps(data_bug_raw,indent=4)
with open('../data_new/bug_raw.json', 'w', encoding='utf-8') as f:
    f.write(json_data)
